﻿using System.Linq;
using HossMvp.Core;
using HossMvp.WinForms;

namespace Sample.Presenters
{
    public class AboutPresenter : AbstractPresenter
    {
        private AbstractView view { get { return this.ViewManager.Views.Single(v => v.Name == "AboutView"); } }

        public AboutPresenter(AbstractModelManager models, AbstractViewManager views)
            : base(models, views, new WinFormsCommandProcessor(new NameDecorator("About")))
        {
            this.CommandProcessor.RegisterCommand("Close", this.CloseView, () => true);
        }

        private void CloseView(CommandContext context)
        {
            this.view.Action("Close").Execute();
            this.ViewManager.Remove(this.view);
        }
    }
}
